angular.module('faApp')
    .service('authService', ['ajaxService', 'sessionService', function (ajaxService, sessionService) {

        this.roleList = function (cfg) {
            return ajaxService.post(ajaxService.getApiUri("ROLE_LIST"), cfg || {});
        };
        this.roleAdd = function (role) {
            return ajaxService.post(ajaxService.getApiUri("ROLE_ADD"), role || {});
        };

        this.roleEdit = function (role) {
            return ajaxService.post(ajaxService.getApiUri("ROLE_EDIT"), role || {});
        };

        this.roleQuery = function (id) {
            return ajaxService.post(ajaxService.getApiUri("ROLE_QUERY"), {groupId: id});
        };

        this.urlList = function (cfg) {
            return ajaxService.post(ajaxService.getApiUri("URL_LIST"), cfg || {});
        };

        this.urlAdd = function (item) {
            return ajaxService.post(ajaxService.getApiUri("URL_ADD"), item || {});
        };

        this.roleIsAuth = function (who) {
            var authFlag = false,
                groups = sessionService.getItem("user.groups") || "";
            if (who == "PRODUCT_CORE_PRICE") {
                if (groups.indexOf() != -1) {
                    authFlag = true;
                }
            }

            return authFlag;
        };

        this.getModule = function (url) {
            var map = {
                "addXcxNews":"shop",
                "listXcxSearchnoRecordUser":"shop",
                "listXcxSearchnoRecord":"shop",
                "updateWxShopInfo.shtml": "shop",
                "deleteWxShopInfo.shtml": "shop",
                "addWxShopInfo.shtml": "shop",
                "listWxShopInfo.shtml": "shop",
                "listFpShopPlayopenApply.shtml": "shop",
                "updateFpShopPlayopenApply.shtml": "shop",
                "detailFpFaTotal.shtml": "operation",
                "updateFpFaTotal.shtml": "operation",
                "yxtActivity.shtml": "shop",
                "yxtActivityDraw.shtml": "shop",
                "addFpShopInformation.shtml": "shop",
                "editFpShopInformation.shtml": "shop",
                "deleteFpShopInformation.shtml": "shop",
                "detailFpShopInformation.shtml": "shop",
                "listFpShopInformation.shtml": "shop",
                "upordownFpShopInformation.shtml": "shop",
                "querylcsmanDetailList.shtml": "fa",
                "querylcsmanstatisticsList.shtml": "fa",
                "deleteFpShopSubject.shtml": "shop",
                "updateFpShopSubject.shtml": "shop",
                "updateFpShopBackground.shtml": "shop",
                "listFpShopBackground.shtml": "shop",
                "addFpShopSubject.shtml": "shop",
                "listFpShopSubject.shtml": "shop",
                "addFpFaUserFeedback.shtml": "operation",
                "listFpFaUserFeedback.shtml": "operation",
                "queryBehaviorHomeList.shtml": "shop",
                "queryBehaviorFooterMenuList.shtml": "shop",
                "queryBehaviorProdList.shtml": "shop",
                "queryBehaviorCustList.shtml": "shop",
                "queryBehaviorFpList.shtml": "shop",
                "falist.html": "shop",
                "faauit.html": "shop",
                "addFpVideo.shtml": "operation",
                "listFpHdFinancingBlind.shtml": "operation",
                "querySalesPerformance.shtml": "salecon",
                "addBatchSalesPrizes.shtml": "salecon",
                "toDataList.shtml": "behavior",
                "queryCaiWuMyOrderListByGaiZao.shtml": "finance",
                "listFpAccountVoucher.shtml" : "finance",
                "queryBankCard.shtml": "finance",
                "queryAccountWithdraw.shtml": "finance",
                "queryProductQDList.shtml": "product",
                "queryUpdateProjectAnnualRevenue.shtml": "product",
                "addBlacklist.shtml": "product",
                "queryAccountWithdrawDetail.shtml": "product",
                "updateProjectAnnualRevenue.shtml": "product",
                "updateWithdrawStatus.shtml": "operation",
                "addPublicActivitiesPer.shtml": "operation",
                "queryBlacklist.shtml": "fa",
                "deleteProject.shtml": "product",
                "addPublicActivities.shtml": "operation",
                "queryBlacklistDetail.shtml": "fa",
                "addProjectCompany.shtml": "product",
                "changepRecruitmentSummary.shtml": "product",
                "publicActivitiesList.shtml": "operation",
                "productSet.shtml": "product",
                "queryList.shtml": "product",
                "updateProjectCompany.shtml": "product",
                "activitiesNowPerson.shtml": "operation",
                "addFl.shtml": "operation",
                "login.shtml": "common",
                "newsManagePer.shtml": "operation",
                "listProjectCompany.shtml": "product",
                "updateFl.shtml": "operation",
                "queryPublicActivities.shtml": "operation",
                "addNews.shtml": "operation",
                "fileUpload.shtml": "common",
                "loginPer.shtml": "operation",
                "queryProjectCompanyView.shtml": "product",
                "deleteFl.shtml": "operation",
                "listNews.shtml": "operation",
                "updatePublicActivities.shtml": "product",
                "deleteProjectCompany.shtml": "product",
                "fLDetail.shtml": "operation",
                "updateProjectForPublish.shtml": "product",
                "queryProjectAttachments.shtml": "product",
                "queryProjectListForPublishPer.shtml": "product",
                "queryFaUserListPer.shtml": "fa",
                "addAction.shtml": "system",
                "listInfoSubscribe.shtml": "product",
                "addProjectAccount.shtml": "product",
                "queryProjectListForPublish.shtml": "product",
                "queryProjectForPublish.shtml": "product",
                "queryFaUserList.shtml": "fa",
                "updateFaUser.shtml": "fa",
                "queryFaUser.shtml": "fa",
                "queryShopFaUser.shtml": "fa",
                "updateShopFaUserForAudit.shtml": "fa",
                "updateProjectAttachments.shtml": "product",
                "addProjectAnnualRevenuePer.shtml": "product",
                "addActionPer.shtml": "system",
                "addProjectAnnualRevenue.shtml": "product",
                "queryCountInfo.shtml": "operation",
                "queryCompany.shtml": "product",
                "addProjectRisk.shtml": "product",
                "deleteNews.shtml": "operation",
                "queryUpdateProjectRisk.shtml": "product",
                "addGroup.shtml": "system",
                "addProductRecommend.shtml": "product",
                "updateGroupInfo.shtml": "system",
                "queryOrderListPer.shtml": "order",
                "queryProjectListForVerifyPer.shtml": "product",
                "updateADFaUser.shtml": "fa",
                "newsContent.sthml": "operation",
                "queryOrderList.shtml": "order",
                "queryProjectListForVerify.shtml": "product",
                "newsDetail.shtml": "operation",
                "queryOrderDetail.shtml": "order",
                "updateCompany.shtml": "product",
                "fpUserFeedBackList.shtml": "operation",
                "projectAllSubscription.shtml": "product",
                "queryProjectForVerify.shtml": "product",
                "updateOrderStatus.shtml": "order",
                "addCompany.shtml": "product",
                "updateProjectForVerify.shtml": "product",
                "querySwitch.shtml": "system",
                "discussManage.shtml": "product",
                "addProjectPer.shtml": "product",
                "updateProjectRisk.shtml": "product",
                "updateFpUserFeedBack.shtml": "operation",
                "updateSwitch.shtml": "system",
                "projectCommentsManage.shtml": "product",
                "addAdvert.shtml": "operation",
                "index.shtml": "common",
                "error.shtml": "common",
                "queryAdvertList.shtml": "operation",
                "updateNews.shtml": "operation",
                "updateAdvert.shtml": "operation",
                "updateUserInfo.shtml": "system",
                "queryApiSetting.shtml": "operation",
                "logout.shtml": "common",
                "queryAdvertInfo.shtml": "operation",
                "addUser.shtml": "system",
                "productRecommendList.shtml": "product",
                "updateApiSetting.shtml": "operation",
                "updateProjectPer.shtml": "product",
                "addApiSetting.shtml": "operation",
                "queryUpdateProjectList.shtml": "product",
                "queryFaUserVisit.shtml": "fa",
                "queryUpdateProject.shtml": "product",
                "updateProjectBaseInfo.shtml": "product",
                "addProject.shtml": "product",
                "addFaUserVisit.shtml": "fa",
                "queryUpdateProjectAccount.shtml": "product",
                "updateProjectAccount.shtml": "product",
                "queryOrderTmpList.shtml": "order",
                "updateOrderTmp.shtml": "order",
                "queryActivitiesMollionsWealth.shtml": "operation",
                "licaishiManagerUserAdd.shtml": "order",
                "queryQuDaoMyOrderListByGaiZao.shtml": "order",
                "queryQuDaoAllOrderListByGaiZao.shtml": "order",
                "queryCaiWuAllOrderListByGaiZao.shtml": "order",
                "queryChanPinMyOrderListByGaiZao.shtml": "order",
                "queryChanPinAllOrderListByGaiZao.shtml": "order",

                "queryFaUserRegisterByMonthCount.shtml": "statistics",
                "queryFaUserRoleCount.shtml": "statistics",
                "queryFaUserCount.shtml": "statistics",
                "queryOrderCountByMonth.shtml": "statistics",
                "queryOrderUserPer.shtml": "statistics",
                "queryOrderFaUserRoleProportion.shtml": "statistics",
                "queryFaUserRoleProportion.shtml": "statistics",
                "queryUserTotalSales.shtml": "statistics",
                "queryCommpanyTotal.shtml": "statistics",
                "queryProductKeyWord.shtml": "statistics"
            };
            return map[url] || "";
        };

    }]);
